package com.chis.coolplat;

import com.chis.jm.bean.ll.RedisMasterBean;
import com.chis.jm.bean.ll.RedisPointBean;
import com.chis.jmdatatimer.comm.JedisConnect;
import com.chis.jmdatatimer.comm.JedisSerializeUtil;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *
 * @Description
 * @Company zwx
 * @author wlj
 * @version 2019年03月16日
 */
public class Test {

    /**
     * 1查询
     * 2删除
     * @param args
     */
    public static void main(String[] args) {
        String opt = args[0];
        String sn = args[1];
        ShardedJedisPool jedisPool = JedisConnect.getInstance().jedisPool;
        ShardedJedis jedis = jedisPool.getResource();

        if(opt.equals("1")){
            jedis.select(4);
            RedisMasterBean masterBean = (RedisMasterBean) JedisSerializeUtil.unserialize(jedis.get(sn.getBytes()));
            System.out.println("===============");
            System.out.println("1:"+masterBean.getSn());
            System.out.println("2:"+masterBean.getMonitorType());
            System.out.println("3:"+masterBean.getUnitCode());
            System.out.println("4:"+masterBean.getUnitName());
            System.out.println("5:"+masterBean.getHostName());
        }else if(opt.equals("2")){
            jedis.select(5);
            Map<byte[], byte[]> map = jedis.hgetAll(sn.getBytes());
            if (map != null){
                for (byte[] in : map.keySet()) {
                    RedisPointBean redisPointBean = (RedisPointBean)JedisSerializeUtil.unserialize(map.get(in));
                    System.out.println("===============");
                    System.out.println("sn:"+redisPointBean.getSn());
                    System.out.println("监测点编码:"+redisPointBean.getMonitorCode());
                    System.out.println("监测点名称:"+redisPointBean.getMonitorName());
                    System.out.println("监测点属性:"+redisPointBean.getMonitorSort());
                    System.out.println("探头编码guid:"+redisPointBean.getPointGuid());
                    System.out.println("探头通道号:"+redisPointBean.getPointChannelNum());
                    System.out.println("仓库编码:"+redisPointBean.getStorage());
                    System.out.println("仓库名称:"+redisPointBean.getStorageName());
                    System.out.println("仓库状态:"+redisPointBean.getStorageState());
                    System.out.println("监测位置:"+redisPointBean.getMonitorAddr());
                    System.out.println("探头值:"+redisPointBean.getPointVal());
                    System.out.println("采集是否启用 0停用 1启用:"+redisPointBean.getIfUse());
                    System.out.println("仓库是否停用 0启用 1停用:"+redisPointBean.getIfStorageStop());
                    System.out.println("仓库是否有苗:"+redisPointBean.getIfBact());
                    System.out.println("仓库工作状态:"+redisPointBean.getWorkState());
                }
            }
        }

//        if(opt.equals("1")){
//
//        } else if(opt.equals("2")){
//            jedis.del(sn.getBytes());
//        }


    }
}
